10. Exercise: Additional Unit Test Topics
Exercise: Additional Unit Test Topics
Test TotalsWithDiscountCalculator
Task Description:
The Starter Project for this exercise contains a modified totals calculator that provides new functionality. Each TotalsWithDiscountCalculator
is initialized with a User
. The user's discount will determine what discount will be applied to the items calculated by the totals calculator.
The TotalsWithDiscountCalculator
reduces the total cost of the items based on any credit
the user has, until the user runs out of credit. It also lowers the user's remaining credit.
The TotalsWithDiscountCalculatorTest
class contains two tests right now:
totalsWithDiscount_getTotals_reducesUserCredit
, which makes multiple purchases with the same user and validates that their credit is reduced.totalsWithDiscounts_regularAndPlatinumUser_returnsDifferentSubtotal
, which makes a purchase with both a regular user and a platinum user and checks that they get the right prices.
For this assignment, we'll use the tools from the two previous units to rewrite these tests.
Task Feedback:
Great job!